<html>
<head><meta charset="utf-8"><title>Another use for `NoUndef` · project-safe-transmute · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/index.html">project-safe-transmute</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Another.20use.20for.20.60NoUndef.60.html">Another use for `NoUndef`</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="196722816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Another%20use%20for%20%60NoUndef%60/near/196722816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Another.20use.20for.20.60NoUndef.60.html#196722816">(May 07 2020 at 03:05)</a>:</h4>
<p>I was pondering the bitwise-ness of <code>Copy</code>, and this got me thinking about <code>match</code> and <code>Eq</code>, where one way to allow more things in patterns would be to require that they're bitwise-comparable for <code>Eq</code>.  But I think that the only way that could be sound at the aggregate level (as opposed to field-by-field) would be if it contained no <code>undef</code>, which I think is one of the markers you're pondering here as a requirement for safe <code>&amp;T</code>-&gt;<code>&amp;[u8]</code>.</p>
<p>Hmm, trying to find the attribute for it got me to <a href="https://github.com/rust-lang/rust/issues/63438" title="https://github.com/rust-lang/rust/issues/63438">https://github.com/rust-lang/rust/issues/63438</a> (which removed said attribute), which has some similar thoughts in it.</p>



<a name="196724990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Another%20use%20for%20%60NoUndef%60/near/196724990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Another.20use.20for.20.60NoUndef.60.html#196724990">(May 07 2020 at 03:56)</a>:</h4>
<p>So you want to match on two values being equal without them being the same type?</p>



<a name="197009427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Another%20use%20for%20%60NoUndef%60/near/197009427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Another.20use.20for.20.60NoUndef.60.html#197009427">(May 09 2020 at 19:54)</a>:</h4>
<p>I was thinking more of being able to <code>memcmp</code> them (of the same type) instead of needing to <code>Eq::eq</code>, like how <code>Copy</code> lets me <code>memcpy</code> instead of <code>Clone::clone</code>.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>